﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SGRapidForm.Foundation.Service.Interface;
using SGRapidForm.Common;
using SGRapidForm.Foundation.Entity;
using DevExpress.Web.ASPxMenu;
using System.Xml;
using DevExpress.Web.ASPxGridView;
using SGRapidForm.Permission.Service.Interface;
using SGRapidForm.Permission.Entity;

namespace SGRapidForm.Foundation
{
    public partial class AutoGenno : System.Web.UI.Page
    {
        private IPermissionService _permissionService = ServiceProxyFactory.Create<IPermissionService>("permissionservice");
        private IFoundationService _foundationService = ServiceProxyFactory.Create<IFoundationService>("foundationservice");
        protected void Page_Load(object sender, EventArgs e)
        {
            JSManager.RegAjax(Header, this.GetType().BaseType);
        }

        /// <summary>
        /// 添加快捷方式
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod]
        public bool SaveFastAdd()
        {
            string userkeyid = ApplicationContext.Current.UserKeyid;
            string pagecode = this.GetType().Name;
            PageEntity page = _permissionService.Page_GetKeyidBypagename(pagecode);
            if (page != null)
            {
                return _permissionService.Shortcuts_Add(userkeyid, page.Keyid);
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 菜单项绑定事件 - 实现操作权限控制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void menuHeader_ItemDataBound(object sender, MenuItemEventArgs e)
        {
            IHierarchyData itemHierarchyData = (IHierarchyData)e.Item.DataItem;
            XmlElement element = (XmlElement)itemHierarchyData.Item;
        }

        /// <summary>
        /// 自定义GridView回调重新绑定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwList_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            gvwList.DataBind();
            gvwList.Selection.UnselectAll();//不选中任何一行
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="keyids">Keyids</param>
        /// <returns>是否删除成功</returns>
        [AjaxPro.AjaxMethod]
        public bool BulkDelete(string keyids)
        {

            return _foundationService.Auto_BulkDeleteAutos(keyids);
        }

    }
    public class AutoGennoManage
    {
        private IFoundationService _foundationService = ServiceProxyFactory.Create<IFoundationService>("foundationservice");

        public List<AutoGennoEntity> PagingGetAutoGenno(Int32 startRecord, Int32 maxRecords, String sortColumns, String filterConditions)
        {
            return _foundationService.PagingGetAutoGenno(startRecord, maxRecords, sortColumns, filterConditions);
        }
        public int PagingGetAutoGennoCount(String filterConditions)
        {
            return _foundationService.PagingGetAutoGennoCount(filterConditions);
        }
    }
}